-- die_pollute
-- created by panyl
-- 死亡污染周围格

return {
    apply = function(prop, baseValue)
        return baseValue + prop[3];
    end,

    -- 死亡触发
    trigger = function(who, prop, arg)
        if who.type ~= OBJECT_TYPE_MONSTER then
            return;
        end

        local arr = { PropM.getPropId("poisoned"), prop[3], tonumber(prop[2]), prop[4] + CombatM.getRound(), "poisoned", };

        local pos = who.dbase:query("pos");
        if not pos then
            pos = who:getOwner();
        end

        local arounds = DungeonM.getAroundGrids(pos);
        for _, pos in pairs(arounds) do
            local grid = DungeonM.getGridByPos(pos);

            -- 未开启的才会被污染
            if not grid:isOpened() and grid.type ~= GRID_TYPE_DOOR then
                grid.polluted = table.deepcopy(arr);

                EventMgr.fire(event.POLLUTE_LEFT_ROUND, { ["pos"] = grid:getPos(), ["left_round"] = prop[4], } );
            end
        end

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
